<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="交易哈希" prop="transactionHash">
        <el-input
          v-model="queryParams.transactionHash"
          placeholder="交易哈希"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="交易时间">
            <el-date-picker
              v-model="dateTimeRange"
              style="width: 240px"
              value-format="yyyy-MM-dd HH:mm:ss"
              type="datetimerange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
      <el-form-item label="发送方" prop="fromAddress">
        <el-input
          v-model="queryParams.fromAddress"
          placeholder="发送方地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接收方" prop="toAddress">
        <el-input
          v-model="queryParams.toAddress"
          placeholder="接收方地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最小金额" prop="minValue">
        <el-input 
          v-model="queryParams.minValue"
          placeholder="最小金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最大金额" prop="maxValue">
        <el-input 
          v-model="queryParams.maxValue"
          placeholder="最大金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table
      v-if="refreshTable"
      v-loading="loading"
      :data="usdtList"
      row-key="id"
    >
    <el-table-column prop="fromAddress" label="发送方" ></el-table-column>
    <el-table-column prop="toAddress" label="接收方"></el-table-column>
    <el-table-column prop="value" label="金额" ></el-table-column>
    <el-table-column label="时间"  prop="blockDatetime" >
      <template slot-scope="scope">
        <span>{{ parseTime(scope.row.blockDatetime) }}</span>
      </template>
    </el-table-column>
      <el-table-column prop="transactionHash" label="交易哈希"></el-table-column>
      
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { usdt3 } from "@/api/usdt/usdt";

export default {
  name: "usdt3",
  dicts: [],
  components: {  },
  data() {
    return {
      // 遮罩层
      loading: false,
      // 显示搜索条件
      showSearch: true,
     
      // 是否展开，默认全部展开
      isExpandAll: true,
      // 重新渲染表格状态
      refreshTable: true,
      total:0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        transactionHash:null,
        toAddress:null,
        fromAddress:null,
        minValue:null,
        maxValue:null,
        minBlockDatetime:null,
        maxBlockDatetime:null
      },
      usdtList:[],
      dateTimeRange:null
    };
  },
  created() {
    this.getList();
  },
  methods: {
    
    /** 查询分类列表 */
    getList() {
      if (this.dateTimeRange) {
        this.queryParams.minBlockDatetime = this.dateTimeRange[0]
        this.queryParams.maxBlockDatetime = this.dateTimeRange[1]
      } else {
        this.queryParams.minBlockDatetime = null
        this.queryParams.maxBlockDatetime = null
        if (!this.queryParams.transactionHash && !this.queryParams.toAddress
      && !this.queryParams.fromAddress && !this.queryParams.minValue && !this.queryParams.maxValue) {
        return 
      }
      }
      
      this.loading = true;
      usdt3(this.queryParams).then(response => {
        this.usdtList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      }).catch(error=>{
        this.loading = false;
      });;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
<style scoped>
.vue-treeselect{
  width:200px !important;
}
</style>
